import LodisNameEnum from "@/enumeration/LodisNameEnum";
import Setting from "../entity/Setting";

export default class SettingService {

    info(): Setting {
        let record = this.getDefault();
        let value = utools.dbStorage.getItem(LodisNameEnum.SETTING);
        record = Object.assign(record, value);
        return record;
    }

    private getDefault(): Setting {
        return {
            maxDownloadCount: 1,
            textExtra: ['json', 'txt', 'java', 'js', 'ts'],
            imageExtra: ['jpeg', 'png', 'webp'],
            videoExtra: ['mp4', 'm3u8', 'flv']
        }
    }

    save(setting: Setting) {
        utools.dbStorage.setItem(LodisNameEnum.SETTING, setting);
    }

}